package com.dstz.org.rest.controller;


import com.dstz.auth.login.AbTokenService;
import com.dstz.auth.model.LoginUser;
import com.dstz.base.api.vo.ApiResponse;
import com.dstz.base.common.constats.AbAppRestConstant;
import com.dstz.base.common.utils.UserContextUtils;
import com.dstz.base.web.controller.AbCrudController;
import com.dstz.org.core.entity.AccountOrg;
import com.dstz.org.core.entity.StockInfo;
import com.dstz.org.core.entity.YanShouInfo;
import com.dstz.org.core.manager.AccountOrgManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.List;

import static com.dstz.base.api.vo.ApiResponse.success;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gaobo
 * @since 2025-03-04
 */
@RestController
@RequestMapping(AbAppRestConstant.ORG_SERVICE_PREFIX + "/accountOrg")
public class AccountOrgController extends AbCrudController<AccountOrg> {
     @Autowired
     private AccountOrgManager accountOrgManager;

     @Override
     protected String getEntityDesc() {
         return "";
     }

    /**
     * @return
     */
    @RequestMapping(value = "getDeptBalance")
    public ApiResponse<Double> getDeptBalance(@RequestParam("orgId") @NotBlank(message = "参数不能为空") String orgId) {
        return success(accountOrgManager.getDeptBalance(orgId));
    }

    /**
     * @return
     */
    @RequestMapping(value = "getStockList")
    public ApiResponse<List<StockInfo>> getStockList(@RequestParam(value = "keyword", required = false) String keyword,@RequestParam(value = "id", required = false) String id) {
        return success(accountOrgManager.getStockList(keyword,id));
    }

    /**
     *
     * @param id 主表的id
     * @return
     */
    @RequestMapping(value = "getChildData")
    public ApiResponse<List<YanShouInfo>> getChildData(@RequestParam(value = "id", required = false) String id) {
        return success(accountOrgManager.getChildData(id));
    }
    /**
     * 获取部门账单
     *
     * @param orgId 部门id
     * @return 账单
     */
    @RequestMapping("getBillListBOrgId")
    public ApiResponse<List<AccountOrg>> getBillListBOrgId(@RequestParam("orgId") @NotBlank(message = "参数不能为空") int orgId) {
        return success(accountOrgManager.listDeptBill(orgId));
    }
}
